{extend name="layout:base" /}

{block name="content"}
<div class="layui-fluid">

    <div class="layui-card">
        <div class="layui-card-header">{$article.name} -  客服： {$article.kfName}</div>
        <div class="layui-card-body">
            <table class="layui-table" lay-filter="test1">
                <thead>
                <tr>
                    <th lay-data="{field:'userName',width:80}">签单人</th>
                    <th lay-data="{field:'money',width:100}">签单金额</th>
                    <th lay-data="{field:'signTime',width:110}">签单时间</th>
                    <th lay-data="{field:'typeName',width:100}">签单类型</th>
                    <th lay-data="{field:'url',width:150}">客户域名</th>
                    <th lay-data="{field:'isSeo'}">优化</th>
                    <th lay-data="{field:'isBeiAn'}">备案</th>
                    <th lay-data="{field:'beiAnText',minWidth:150}">备案资料</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>{$article.userName}</td>
                    <td>{$article.money}</td>
                    <td>{$article.signTime}</td>
                    <td>{$article.typeName}</td>
                    <td>{$article.url}</td>
                    <td>{if condition="$article.isSeo==1"}是{/if} {if condition="$article.isSeo==0"}否{/if}</td>
                    <td>{if condition="$article.isBeiAn==1"}是{/if} {if condition="$article.isBeiAn==0"}否{/if}</td>
                    <td>{$article.beiAnText}</td>
                </tr>
            </table>
            <table class="layui-table" lay-filter="test2">
                <thead>
                <tr>
                    <th lay-data="{field:'kfName',style:'background-color: #009688; color: #fff;'}">客服</th>
<!--                    <th lay-data="{field:'dataGetTime',style:'background-color: #009688; color: #fff;'}">资料收集时间</th>-->
                    <th lay-data="{field:'special',style:'background-color: #009688; color: #fff;'}">特殊要求</th>
                    <th lay-data="{field:'content'}">备注</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>{$article.kfName}</td>
<!--                    <td>{$article.dataGetTime}</td>-->
                    <td>{$article.special}</td>
                    <td>{$article.content}</td>
                </tr>
            </table>
            <table class="layui-table" lay-filter="test3">
                <thead>
                <tr>
                    <th lay-data="{field:'editName'}">编辑</th>
                    <th lay-data="{field:'editTime'}">分配时间</th>
                    <th lay-data="{field:'templateTime'}">模版确认</th>
                    <th lay-data="{field:'templateUrl'}">模版地址</th>

                    <th lay-data="{field:'techName'}">技术</th>
                    <th lay-data="{field:'techTime'}">分配时间</th>
                    <th lay-data="{field:'techEndTime'}">框架完成时间</th>
                    <th lay-data="{field:'techTxt'}">框架备注</th>
                    <th lay-data="{field:'dataEndTime'}">资料传完时间</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>{$article.editName}</td>
                    <td>{$article.editTime}</td>
                    <td>{$article.templateTime}</td>
                    <td>{$article.templateUrl}</td>
                    <td>{$article.techName}</td>
                    <td>{$article.techTime}</td>
                    <td>{$article.techEndTime}</td>
                    <td>{$article.techTxt}</td>
                    <td>{$article.dataEndTime}</td>
                </tr>
            </table>
        </div>
    </div>

    <div class="layui-card">
        <div class="layui-card-header">上线确认</div>
        <div class="layui-card-body">
            <form class="layui-form">
                <input type="hidden" name="id" value="{$article.id}">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>时间</th>
                        <th>网站完成确认书</th>
                        <th></th>
                    </tr>
                    </thead>
                    <tr>
                        <td>
                            <input type="hidden" name="websiteName" value="{$article.name}">
                            <input type="text" name="endTime" id="endTime" value="" autocomplete="off" class="layui-input" lay-verify="required">
                        </td>
                        <td>
                            <div class="layui-inline">
                                <input type="text" name="endImg" id="imageurl" value="" autocomplete="off" class="layui-input"/>
                            </div>
                            <div class="layui-inline">
                                <input type="button" id="btnImgUpload" value="上传图片" class="layui-btn"/>
                            </div>
                            <div class="layui-inline"><div class="layui-form-mid layui-word-aux" id="imgtxt"></div></div>
                        </td>
                        <td>
                            <button class="layui-btn" lay-submit="" lay-filter="btn_websiteEnd">保存</button>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script>
    KindEditor.ready(function(K) {
        var editor = K.editor({
            allowFileManager : true
        });
        K('#btnImgUpload').click(function () {
            editor.loadPlugin('image', function () {
                editor.plugin.imageDialog({
                    imageUrl: K('#imageurl').val(),
                    clickFn: function (url, title, width, height, border, align) {
                        K('#imageurl').val(url);
                        editor.hideDialog();
                        K('#imageView').html('');
                        K('#imageView').append('<img src="' + url + '" height="50">');
                    }
                });
            });
        });

    });
</script>
<script>

    layui.config({
        base: '__STATIC__/layuiadmin/' //静态资源所在路径
    }).extend({
        index: '/lib/index' //主入口模块
    }).use(['index', 'table','form','laydate'], function () {
        var $ = layui.$, form = layui.form, layer = layui.layer, table = layui.table, laydate = layui.laydate;

        laydate.render({elem: '#endTime', type: 'datetime', value: new Date(),});
        table.init('test1');
        table.init('test2');
        table.init('test3');

        //编辑确认模版 ，发邮件给技术
        form.on('submit(btn_websiteEnd)', function (data) {
            layer.open({
                content: '确认完成?'
                ,btn: ['确定', '取消']
                ,yes: function(index, layero){
                    var websiteName=data.field.websiteName;
                    $.post("{:url('websiteEnd')}",data.field, function (result) {
                        if (result['code'] == 0) {
                            layer.msg(result['msg'], {icon: 1, time: 1000}, function () {
                                $.post("{:url('sendMail')}",{to:result['email'],name:'“浙江四为网络” - “'+websiteName+'” 网站上线',body:'网站上线啦~ 快去看看!'}, function (result) {
                                    if (result['code'] == 0) {
                                        layer.msg(result['msg'], {icon: 1, time: 1000}, function () {
                                            location.reload();
                                        });
                                    } else {
                                        // layer.msg(result['msg'], {icon: 3, time: 3000});
                                        layer.msg(result['msg'], {icon: 3, time: 3000},function () {
                                            location.reload();
                                        });
                                    }
                                });
                            });
                        } else {
                            layer.msg(result['msg'], {icon: 3, time: 3000});
                        }
                    });
                    form.render();
                    layer.close(index);
                }
                ,btn2: function(index, layero){
                    layer.close(index);
                }
            });

            return false;
        });
    });
</script>
{/block}